<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>滚动渐变导航栏</title>
    <link rel="stylesheet" href="daohang.css">
</head>
<body>
    <header>
        <a href="#" class="logo">logo</a>
        <ul>
            <li><a href="#">探索车型</a></li>
            <li><a href="#">官方商城</a></li>
            <li><a href="#">车主服务</a></li>
            <li><a href="#">科技创新</a></li>
            <li><a href="#">奔驰天下</a></li>
            <li><a href="#">预约品鉴</a></li>
        </ul>
    </header>
    <section class="banner1"></section>
    <section class="banner2"></section>
    <script>
        window.addEventListener("scroll",()=>{
            let header=document.querySelector("header");
            header.classList.toggle("sticky",window.scrollY>0);
        })
    </script>
</body>
</html>